<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>待处理详情页</title>
    <link rel="stylesheet" href="../../lib/layui/css/layui.css">
</head>

<style>
    .tdAdapt {
        font-size: 16.0pt;
        word-wrap: break-word;
        word-break: break-all;
    }

    .textarea {
        margin-right: 3px;
    }

    .divarea {
        margin-bottom: 5px;
    }

    .tub {
        font-size: 16px;
        margin-right: 5px;
    }
</style>

<body>
<div class="ok-body" style="background: #F8F8F8">
    <div class="layui-row ">
        <div class="layui-col-md9" style="background-color:#f8f8f8;">
            <div class="layui-row">
                <hr class="layui-bg-gray">
                <fieldset class="layui-elem-field">
                    <legend>警情详情 <span class="layui-badge layui-bg-orange">待处理</span></legend>
                    <hr class="layui-bg-gray">
                    <div>
                        <div style="background: #d2d2d2">
                            <div style="width: 80%;height: 100%;margin: 0 auto;">
                                <div class="layui-collapse" lay-filter="caseData">
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title" style="font-size: 16px"><span id="caseDataChange">隐藏</span>警情信息
                                        </h2>
                                        <div class="layui-colla-content layui-show" style="background-color:#fdfdfd;">
                                            <div style="background-color:#fdfdfd;">
                                                <iframe scrolling="no" frameborder="0"
                                                        src="../caseCommonData/caseData.html" width="100%"
                                                        height="700px" id="caseData"
                                                        onload="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>700?fdh:700);"></iframe>

                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div style="background-color:#fdfdfd;margin-top: 10px;padding-top: 20px;">
                                    <iframe scrolling="no" frameborder="0" src="../caseCommonData/processData.html"
                                            width="100%"
                                            height="700px" id="processData"
                                            onload="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>700?fdh:700)"></iframe>
                                </div>
                            </div>

                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-col-md3" style="background-color:#f8f8f8;">
            <div class="layui-row">
                <hr class="layui-bg-gray"/>
                <fieldset class="layui-elem-field">
                    <legend>分派信息</legend>
                    <div style="background-color: #f8f8f8;height: auto;margin:15px 20px 0 30px">
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <i class="tub layui-icon layui-icon-username" style="color: #1E9FFF;"></i>
                                <label>分派者 : </label>
                                <span id="askPoliceName">加载中</span>
                            </div>
                            <div class="layui-form-item">
                                <i class="tub layui-icon layui-icon-home" style="color: #FF5722;"></i>
                                <label>分派单位 : </label>
                                <span id="askDepartmentName">加载中</span>
                            </div>
                            <div class="layui-form-item">
                                <i class="tub layui-icon layui-icon-log" style="color: #FFB800;"></i>
                                <label>分派时间 : </label>
                                <span id="askTime">加载中</span>
                            </div>
                            <div class="layui-form-item">
                                <i class="tub layui-icon layui-icon-read" style="color: #009688;"></i>
                                <label>警情描述 : </label>
                                <span id="caseDescription">加载中</span>
                            </div>
                            <div class="layui-form-item">
                                <i class="tub layui-icon layui-icon-diamond" style="color: #ff1e31;"></i>
                                <label>督办级别 : </label>
                                <span id="procLevel">加载中</span>
                            </div>
                        </form>
                    </div>
                </fieldset>
                <br>
                <br>
                <br>
                <fieldset class="layui-elem-field">
                    <legend>警情指派</legend>

                    <div style="background-color: #f8f8f8;height: auto;margin:10px 20px 0 20px">

                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label" style="text-align: left;">负责人</label>
                                <div class="layui-input-block">
                                    <select id="police" name="police" lay-filter="police">
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <button type="button" class="layui-btn" lay-submit lay-filter="add" id="submit"
                                        style="float: right">指派
                                </button>
                            </div>
                        </form>

                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>
<br/>
</body>

<script src="../../lib/layui/layui.js"></script>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/selectMore.js"></script>
<script src="../../js/application.js"></script>
<script>
    let processDataHeight = 0
    //获取警情详细内容页
    function getCaseData(caseId) {
        $("#caseData").on("load", function () {
            var data = {caseId: caseId}
            this.contentWindow.getParentData(data)
        })
    }
    //催办过程页
    function getUrgingData(processId) {
        $("#processData").on("load", function () {
            var data = {processId: processId}
            this.contentWindow.getParentData(data)
        })
    }

    var processId = GetQueryString("processid");
    var caseId = GetQueryString("caseid");
    getCaseData(caseId)
    getUrgingData(processId)
    //催办信息展示
    $.ajax({
        url: mainUri + "/vProcInfo/selectByProcessId",
        data: {processId: processId},
        type: "Post",
        dataType: "json",
        success: function (data) {
            var newUrgingData = data.data[data.data.length - 1]
            $("#askPoliceName").html(newUrgingData.fullName);
            $("#askDepartmentName").html(newUrgingData.askForDepartmentName);
            $("#askTime").html(newUrgingData.askForTime);
            $("#caseDescription").html(newUrgingData.caseDescription);
            $("#procLevel").html(newUrgingData.procLevel);
        },
        error: function () {
            console.log("数据加载失败")
        }
    });

    layui.use(['layedit', 'upload', 'element'], function () {
        var layedit = layui.layedit;
        var upload = layui.upload;
        var element = layui.element;
        //警情详细内容显示隐藏
        element.on('collapse(caseData)', function (data) {
            if (processDataHeight == 0) {
                processDataHeight = $("#processData").height();
            }
            if (!data.show) {
                if (processDataHeight < 800) {
                    $("#processData").height(800)
                }
                $("#caseDataChange").html("显示")
            } else {
                $("#processData").height(processDataHeight)
                $("#caseDataChange").html("隐藏")
            }
        });
    });

    var rolename = " ";
    layui.use(['form', 'laydate'], function () {
        var form = layui.form;
        let $ = layui.jquery;
        var layer = layui.layer

        /*动态加载警员下拉框*/
        $.ajax({
            type: 'post',
            url: mainUri + "/vUserInfo/selectPolice",
            data: {'departmentId': police.departmentId, 'grade': 4}
        }).done(function (datas) {
            var list = datas['data'];
            var option;
            for (var i = 0; i < list.length; i++) {
                option += "<option value='" + list[i]['policeId'] + "'>" + list[i]['fullName'] + "</option>";
                $("#police").html(option);
                rolename = list[i]['roleName'];
            }
            form.render('select');
        }).fail(function () {
            layer.msg("服务器错误");
        });

        //指派警员弹窗
        $("#submit").on("click", function () {
            layer.confirm('指派人员已确定？', {
                btn: ['确定', '取消']//按钮
            }, function (index) {
                showloading(true)
                layer.close(index);
                startAssign();
            });
        })
    });

    //指派警员
    function startAssign() {
        var policeId = $("#police").val();
        var policename = $("#police").find("option:selected").text();
        $.ajax({
            url: mainUri + "/caseOperNote/insertOne",
            data: {
                "processId": processId,
                "procRemark": "本警情已指派给" + policename + "(" + rolename + ")开始处理",
                "nextPoliceId": policeId
            },
            type: "post",
            dataType: "json",
            success: function (result) {
                showloading(false)
                if (result.code == 0) {
                    layer.msg(result.msg, {
                        icon: 1, time: 1500, end: function () {
                            window.opener.location.href = window.opener.location.href;
                            window.close();
                        }
                    })
                }
            },
            error: function () {
                showloading(false)
                alert("服务器错误");
            }
        });
    }

    function caseReturnData(returnData) {

    }

    function processReturnData(returnData) {
        $("#processData").height(returnData.height)
        processDataHeight = returnData.height
    }
    //文档下载窗口
    function showProcessContent(clickId) {
        layui.use(['element', 'layer', 'okLayer'], function () {
            let okLayer = layui.okLayer;
            okLayer.open("查询条件", "../caseCommonData/fileData.html?processId=" + clickId, "35%", "50%", function (layero) {
                let iframeWin = window[layero.find("iframe")[0]["name"]];
            }, function () {

            })
        })
    }

</script>

</html>